/**
 * Matching Object Filter
 */
const whatIsInAName = (objs, srcObj) => {
  const arr = objs.filter(obj => {
    for (const key in srcObj) {
      if (!obj.hasOwnProperty(key)) return false;
      if (obj[key] !== srcObj[key]) return false;
    }
    return true;
  });
  return arr;
};

console.log(
  whatIsInAName(
    [{ apple: 1, bat: 2 }, { apple: 1 }, { apple: 1, bat: 2, cookie: 2 }],
    { apple: 1, cookie: 2 }
  )
);
